package main

import (
	"fmt"
	"sync"
	"time"
)

//var wait sync.WaitGroup

func shopping(name string, wait *sync.WaitGroup) {
	fmt.Println(name, "来购物")
	time.Sleep(1 * time.Second)
	fmt.Println(name, "购物结束")
	wait.Done()
}

func main() {
	var wait sync.WaitGroup
	var now = time.Now()
	wait.Add(3)
	go shopping("张三", &wait)
	go shopping("里斯", &wait)
	go shopping("王五", &wait)
	wait.Wait()
	fmt.Println(time.Since(now))
}
